<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<html>
	<head>
		<title>添加VIP服务</title>
		<script type="text/javascript">
			$(document).ready(function(){
				$("#vipServiceForm").validationEngine({
					ajaxFormValidation: true,
					onAjaxFormComplete: function (status, form, json, options){
						if (json === 1) {
							art.dialog.tips("<label class='success'>添加成功！</label>", 1);
			        		$("button").attr("disabled", true);
							window.parent.location.reload();
						}else{
							art.dialog.tips("<label class='error'>添加失败，请刷新页面重试！</label>", 1);
						}
					}
				});

				$("#vipUser").autocomplete("${ctx}/autoCompletion.html?level=2",{
					minChars: 0,
					width: 188,
					mustMatch: false,
					matchContains: true,
					extraParams:{
						keyword:function(){
							return $.trim($("#vipUser").val());
						}
					},
			        parse: function(data) {
			            return $.map(eval(data), function(row) {
			                return {
			                    data: row,
			                    value: row.username,
			                    result: row.nickname
			                }
			            });
			        },
			        formatItem: function(row, i, max) {
			        	return row.username + "( " + row.nickname + " )";
			        }
		    	}).result(function(event, row, formatted) {		    			
		    		$("#vipId").val(row.id);
	   			});
	   			
				$("#editorUser").autocomplete("${ctx}/autoCompletion.html?level=32",{
					minChars: 0,
					width: 188,
					mustMatch: false,
					matchContains: true,
					extraParams:{
						keyword:function(){
							return $.trim($("#editorUser").val());
						}
					},
			        parse: function(data) {
			            return $.map(eval(data), function(row) {
			                return {
			                    data: row,
			                    value: row.username,
			                    result: row.nickname
			                }
			            });
			        },
			        formatItem: function(row, i, max) {
			        	return row.username + "( " + row.nickname + " )";
			        }
		    	}).result(function(event, row, formatted) {
		    		$("#editorId").val(row.id);
	   			});
			});
		</script>
	</head>
	<body>
		<div class="container_16">
			<div class="grid_16">
				<div class="content_top">
					<span>添加VIP服务</span>
				</div>
				<div class="content_bottom">
					<form id="vipServiceForm" action="${ctx}/saveVipService.html" method="post">
						<table cellpadding="0" cellspacing="0" style="margin-left: 60px; width: 350px;">
							<tr>
								<td>
									<label>
										用户：
									</label>
								</td>
								<td>
									<input type="text" id="vipUser" name="vipUser" class="validate[required] input" />
									<input type="hidden" id="vipId" name="vipServiceVo.vipId" />
								</td>
							</tr>
							<tr>
								<td>
									<label>
										专业顾问：
									</label>
								</td>
								<td>
									<input type="text" id="editorUser" name="editorUser" class="validate[required] input" />
									<input type="hidden" id="editorId" name="vipServiceVo.editorId" />
								</td>
							</tr>
							<tr>
								<td>
									<label>
										付款方式：
									</label>
								</td>
								<td>
									<select id="payment" name="vipServiceVo.payment" class="validate[required] input_100">
										<option value="1">
											网银
										</option>
										<option value="2">
											现金
										</option>
									</select>
									<input type="checkbox" id="ispay" name="vipServiceVo.ispay" value="1" />
									<label>
										已付款
									</label>	
								</td>
							</tr>
							<tr>
								<td>
									<label>
										服务费用：
									</label>
								</td>
								<td>
									<input type="text" id="price" name="vipServiceVo.price" class="validate[required] input"  />
								</td>
							</tr>
							<tr>
								<td>
									<label>
										专业顾问费用：
									</label>
								</td>
								<td>
									<input type="text" id="repay" name="vipServiceVo.repay" class="validate[required] input"  />
								</td>
							</tr>
							<tr>
								<td>
									<label>
										开始时间：
									</label>
								</td>
								<td>
									<input type="text" id="startTime" name="vipServiceVo.startTime" class="validate[required,custom[date]] input" />
									<script>										        
										datePickerController.createDatePicker({ 
										    formElements:{"startTime":"%Y-%m-%d"}
									    });
								    </script>
								</td>
							</tr>
							<tr>
								<td>
									<label>
										结束时间：
									</label>
								</td>
								<td>
									<input type="text" id="endTime" name="vipServiceVo.endTime" class="validate[required,custom[date]] input" />
									<script>										        
										datePickerController.createDatePicker({ 
										    formElements:{"endTime":"%Y-%m-%d"}
									    });
								    </script>
								</td>
							</tr>
							<tr>
								<td>
									&nbsp;
								</td>
								<td>
									<label class="btn">
										<input type="submit" value="添加" />
									</label>
								</td>
							</tr>
						</table>
					</form>
				</div>
			</div>		
		</div>
	</body>
</html>
